Euler tour technique

The Euler tour technique (ETT), named after Leonhard Euler, is a method in graph theory for representing trees. The tree is viewed as a directed graph that contains two directed edges for each edge in the tree. The tree can then be represented as a Eulerian circuit of the directed graph, known as the Euler tour representation (ETR) of the tree. The ETT allows for efficient, parallel computation of solutions to common problems in algorithmic graph theory. It was introduced by Tarjan and Vishkin in 1984.[1]

Contents

Construction

Given an undirected tree presented as a set of edges, the Euler tour representation (ETR) can be constructed in parallel as follows:

Construct an edge list (called succ) in Euler tour order by setting pointers succ(u,v) for all edges (u,v) in parallel according to the following rule:

\mathrm{succ}(u,v)=\begin{cases} 
                 \mathrm{next}(v,u) & \mathrm{next}(v,u)\neq \mathrm{nil} \\
                 \mathrm{first}(v)&\text{otherwise}
                \end{cases}

The resulting list succ will be circular.

The overall construction takes work W(n) = O(sort(n)) (the time it takes to sort n items in parallel) if the tree has n nodes, as in trees the number of edges is one less than the number of nodes.

Roots, advance and retreat edges

If the tree has a root, we can split the circular list succ at that root. In that case, we can speak of advance and retreat edges: given a pair of nodes u,v, the first occurrence of either (u,v) or (v,u) in the ETR is called the advance edge, and the second occurrence is called the retreat edge. This appeals to the intuition that the first time such an edge is traversed the distance to the root is increased, while the second time the distance decreases.

Applications

Rerooting the tree can be done in constant time O(1) by splitting the circular list succ at the new root.

All of the following problems can be solved in O(Prefix sum(n)) (the time it takes to solve the prefix sum problem in parallel for a list of n items):

  1. Classifying advance and retreat edges: Do list ranking on the ETR and save the result in a two-dimensional array A. Then (u,v) is an advance edge iff A(u,v) < A(v,u), and a retreat edge otherwise.
  2. Determine the level of each node: Do a prefix sum on the ETR, where every advance edge counts as 1, and every retreat edge counts as −1. Then the value at the advance edge (u,v) is the level of v.
  3. Number of nodes in a subtree rooted at v: determine advance edge (u,v), and the retreat edge (u,v) in parallel, and then count the number of advance edges between (u,v) and (u,v) using prefix sum.
  4. The depth-first search index of a node v: count the number of advance edges up to and including (u,v).

References

  1. ^ R.E. Tarjan, U. Vishkin: "Finding biconnected components and computing tree functions in logarithmic parallel time". Proceedings of FOCS 1984, 12–20.